package top.forforever.srb.core.controller.api;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.forforever.srb.common.result.R;
import top.forforever.srb.common.util.JwtUtils;
import top.forforever.srb.core.service.IntegralGradeService;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;

/**
 * <p>
 * 积分等级表 前端控制器
 * </p>
 *
 * @author Mr.Jiang
 * @since 2023-04-29
 */
@RestController
@RequestMapping("/api/core/integralGrade")
public class ApiIntegralGradeController {

    @Autowired
    private IntegralGradeService integralGradeService;

    @GetMapping("getBorrowAmount")
    public R getBorrowAmount(HttpServletRequest request) {
        String token = request.getHeader("token");
        Long userId = JwtUtils.getUserId(token);
        BigDecimal borrowAmount = integralGradeService.getBorrowAmount(userId);
        return R.ok().data("borrowAmount",borrowAmount);
    }

}

